@extends('layouts.app')

@section('title', config('index_title'))
@section('content')
<div class="sy_header">
    <a href="/">
        <img src="/fontpage/img/juziwu.png" class="logo">
    </a>
    @if(request()->get('jp',0) == 0)
        <a style="line-height: 50px;font-size: 14px;" href="{{changeUrl()}}jp=1" >日語</a>
    @else
        <a style="line-height: 50px;font-size: 14px;"  href="{{changeUrl()}}jp=0" >中文</a>
    @endif
    	<form class="form-horizontal" id="lls" action="{{ JpUrl(route('good.list')) }}">
        {{ csrf_field() }}
        <input name="jp" value="{{request()->get('jp', 0)}}" type="hidden" />
    <input type="text" name="keyword" id="search-key" value="" placeholder="{{translate('搜索商品')}}">
    <a id="search" onclick="$('#lls').submit()"><img src="/fontpage/img/sousuo.png" class="suosou"></a>
    </form>
</div>

<div class="container" id="container">
    <div class="wrapper">
        <div id="minHeight">
            <link href="/fontpage/css/swiper.min.css" rel="stylesheet">
            <script src="/fontpage/js/swiper.jquery.min.js"></script><!-- 轮播图JS-->
            <!--<div class="banner_logo" style="background:white;">
                <div class="index_logo" style=" width: 96%">
                    <a class="index_head_a1">
                        <img style=" margin-top: 8px;" src="img/juziwu.png" width="130" height="45" />
                    </a>
                    <a href="/Goods/Index/" class="index_head_a2">
                        <img src="img/navbar_search2x.png" width="25" />
                    </a>
                </div>
            </div>-->
            <div class="index_max_width" style="max-width: 640px; min-width: 320px;">
                <div class="slider main_visual">
                    <!-- star 轮播图 -->
                    <div class="swiper-container swiper-container-horizontal">
                        <div class="swiper-wrapper" >
                                @foreach(\DB::table('links')->where('type', 3)->orderBy('listorder', 'asc')->orderBy('id', 'desc')->get() as $row)
                                    <div class="swiper-slide" data-swiper-slide-index="0">
                                        <a href="javascript:;"><img src="upload/{{$row->thumb}}"></a>
                                    </div>
                                @endforeach



                        </div>
                        <div class="swiper-pagination"><span class="swiper-pagination-bullet swiper-pagination-bullet-active"></span><span class="swiper-pagination-bullet"></span><span class="swiper-pagination-bullet"></span></div>
                    </div>
                    <!-- end 轮播图 -->
                </div>
                <!--index-main-->
                <div>
                    <!--limit time top 10 in main-->
                    <script src="/fontpage/js/limittime.js"></script>


                    <script type="text/javascript">


                        $(function () {
                            var endTime = Date.parse($("#limitTime").val()) / 1000;

                            count_time(endTime);   // 限时抢购倒计时
                        });

                    </script>
                </div>


                <div class="index_user_center" style="display: flex;flex-wrap: wrap;">



						@foreach(\DB::table('links')->where('type', 2)->orderBy('listorder', 'asc')->orderBy('id', 'desc')->get() as $row)

                            <div class="index_u">
                                <a href="{{JpUrl($row->url)}}">
                                    <div style="background:#FE5400;">
                                        <img src="upload/{{$row->thumb}}">
                                    </div>
                                    <span>{{translate($row, 'name')}}</span>
                                </a>
                            </div>

                        @endforeach



                </div>




                <div class="index_sale">
                    <span class="index_sale_z1" id="ganhuo">{{translate('热销产品')}}
</span>
                    <span class="new">New</span>
                    <a href="chanpinliebiao.php">

                    </a>
                </div>
                <div class="index_floor_list">
                    <ul id="ghList">

                        @foreach(\DB::table('goods')->where('recommend', 1)->orderBy('listorder', 'asc')->orderBy('id', 'desc')->limit(3)->get() as $row)

                            <a href="{{JpUrl('/good/detail?id='.$row->id)}}">
                                <li style="width: 33%; height: 120px;">
                                    <div class="index_floor_bk2">
                                        <div class="index_floor_list_d3">
                                            <img src="{{url('upload/'.$row->thumb)}}" style="width:90px;height:90px;">
                                        </div>
                                        <div class="index_floor_list_d4" style="display:block;">
                                            <p class="index_floor_list_pa">{{translate($row, 'title')}}</p>
                                            <span class="index_floor_list_pb">￥{{$row->price}}</span>
                                        </div>
                                    </div>
                                </li>
                            </a>
                       @endforeach

                    </ul>
                </div>
                <!---蔬菜类 商品列表结束-->


                <div class="index_sale">
                    <span class="index_sale_z1" id="ganhuo" >{{translate('推荐产品')}}</span>
                    <span class="new">New</span>
                    <a href="chanpinliebiao.php">

                    </a>
                </div>
                <div class="index_floor_list">
                    <ul id="ghList">
                        @foreach(\DB::table('goods')->where('recommend', 2)->orderBy('listorder', 'asc')->orderBy('id', 'desc')->get() as $row)
                            <a href="{{JpUrl('/good/detail?id='.$row->id)}}">
                                <li style="width: 33%; height: 120px;">
                                    <div class="index_floor_bk2">
                                        <div class="index_floor_list_d3">
                                            <img src="{{url('upload/'.$row->thumb)}}" style="width:90px;height:90px;">
                                        </div>
                                        <div class="index_floor_list_d4" style="display:block;">
                                            <p class="index_floor_list_pa">{{translate($row, 'title')}}</p>
                                            <span class="index_floor_list_pb">￥{{$row->price}}</span>
                                        </div>
                                    </div>
                                </li>
                            </a>
                        @endforeach

                    </ul>
                </div>
                <!---干活类 商品列表结束-->
                <!---水果类 商品列表开始-->
                <div class="index_sale">
                    <span class="index_sale_z1" id="ganhuo" >{{translate('最新产品')}}
</span>
                    <span class="new">New</span>
                    <a href="chanpinliebiao.php">

                    </a>
                </div>
                <div class="index_floor_list">
                    <ul id="ghList">


                            @foreach(\DB::table('goods')->where('recommend', 3)->orderBy('listorder', 'asc')->orderBy('id', 'desc')->limit(3)->get() as $row)

                            <a href="{{JpUrl('/good/detail?id='.$row->id)}}">
                                <li style="width: 33%; height: 120px;">
                                    <div class="index_floor_bk2">
                                        <div class="index_floor_list_d3">
                                            <img src="{{url('upload/'.$row->thumb)}}" style="width:90px;height:90px;">
                                        </div>
                                        <div class="index_floor_list_d4" style="display:block;">
                                            <p class="index_floor_list_pa">{{translate($row, 'title')}}</p>
                                            <span class="index_floor_list_pb">￥{{$row->price}}</span>
                                        </div>
                                    </div>
                                </li>
                            </a>
                       @endforeach

                    </ul>
                </div>
                <!---水产类 商品列表开始-->
                <div class="go_top" onclick="go_top()">
                    <img src="img/totop.png" width="50" height="50">
                </div>

            </div>

            <style>
                .time_bg_k {
                    position: absolute;
                    top: 0px;
                }

                .time_bg_title {
                    float: left;
                    font-size: 8px;
                    margin-top: 5px;
                    margin-left: 5px;
                    color: #99CC33;
                    display: block;
                    width: 16px;
                    line-height: 8px;
                }

                .time_bg {
                    float: left;
                    font-size: 14px;
                    display: block;
                    line-height: 18px;
                    font-weight: bold;
                    margin: 4px 0px 0px 0px;
                    border-radius: 5px;
                    width: 20px;
                    height: 18px;
                    background-color: #99CC33;
                    color: #fff;
                }

                .time_bg_dian {
                    margin-top: 5px;
                    text-align: center;
                    float: left;
                    font-size: 14px;
                    display: block;
                    line-height: 18px;
                    font-weight: bold;
                    width: 5px;
                    height: 18px;
                    color: #99CC33;
                }

                .time_bg_start {
                    background-color: #999;
                }

                .color_start {
                    color: #999;
                }

                .go_top {
                    position: fixed;
                    z-index: 10000;
                    bottom: 50px;
                    right: 20px;
                    display: none;
                }

                .index_time_list_waiceng {
                    position: relative;
                    z-index: 1;
                    top: 0px;
                    bottom: 48px;
                    left: 0;
                }
            </style>
            <script src="/fontpage/js/iscroll.js"></script>
            <script type="text/javascript">

                var myScroll;

                function loaded() {
                    myScroll = new iScroll('wrapper', {adeScrollbars: false, vScroll: false, hScrollbar: false});
                }

                document.addEventListener('DOMContentLoaded', loaded, true);


                function each_time_bg() {

                    $(".time_bg_k").each(function () {

                        var statime = $(this).attr('statime');
                        var endtime = $(this).attr('endtime');

                        time_bg_k(statime, endtime, $(this));
                    });

                }


                function time_bg_k(statime, endtime, that) {   //首页活动倒计时 2016 08 25 zchuang

                    var time_overdue = 0;
                    var type = '';

                    if (statime <= 0) { //已经开始

                        time_overdue = endtime;
                        type = 'end';
                    } else {          //未开始

                        time_overdue = statime; //距离开始时间
                        type = 'start';
                    }

                    var timeout_run = setInterval(function () {


                        if (time_overdue > 0) {

                            var day = Math.floor(time_overdue / (3600 * 24));
                            var hour = Math.floor((time_overdue - day * 3600 * 24) / 3600);
                            var minute = Math.floor((time_overdue - day * 3600 * 24 - hour * 3600) / 60);
                            var second = Math.floor((time_overdue - day * 3600 * 24 - hour * 3600) - minute * 60);

                            time_overdue--;

                            if (day > 99) {
                                day = 99;
                            }
                            if (day <= 0) {
                                that.children('.D').hide();
                            } else {
                                that.children('.D').html(charLeftAll(day));
                            }

                            that.children('.H').html(charLeftAll(hour));
                            that.children('.I').html(charLeftAll(minute));
                            that.children('.S').html(charLeftAll(second));

                        } else {
                            if (type == 'start') {

                                time_overdue = endtime;
                                that.children('.time_bg').removeClass('time_bg_start');
                                that.children('.time_bg_title').removeClass('color_start');
                                that.children('.time_bg_title').removeClass('time_bg_dian');
                                that.children('.time_bg_title').html('距离结束');

                            } else {

                                clearInterval(timeout_run);
                                that.html('<span class="time_bg_title color_start">活动结束</span>');

                            }
                        }

                    }, 1000);


                }

                function open() {
                    $(".ad_modal").css("display", "block");
                    $(".ad-bg").css("display", "block");
                    $(".ad_modal").addClass("fadeIn");
                }

                function close_ad() {
                    $(".ad_modal").removeClass("fadeIn");
                    $(".ad-bg").css("display", "none");
                    $(".ad_modal").css("display", "none");
                }


                var mySwiper = new Swiper('.swiper-container', {
                    direction: 'horizontal',
                    autoplay: 5000, //可选选项，自动滑动
                    pagination: '.swiper-pagination', //分页器
                    loop: true,
                    setWrapperSize: true
                })


                var is = 0;

                function is_login(type, is_need_login) {

                    var is_login = false;

                    var c_url = '';
                    switch (type) {

                        case '1':
                            c_url = '/Content/my/order';
                            break;
                        case '2':
                            c_url = '/Content/my/qingsongtui';
                            break;
                        case '4':
                            c_url = '/Content/my/topUp';
                            break;
                        case '5':
                            c_url = 'http://sz.34580.com/Activities/songli/index.html?v=1.03';
                            break;
                        case '6':
                            c_url = '/Content/transfer/index?siteid=1';
                            break;
                        case '7':
                            c_url = '/Content/dachu/index?siteid=1';
                            break;
                        case '8':
                            var now_city = '苏州市';
                            if (now_city == '北京市') {
                                c_url = '/Content/my/red';
                            } else {
                                c_url = 'http://wechat-1.34580.com/reports';
                            }
                            break;
                        default:
                            c_url = '';
                    }

                    if (is_need_login) {

                        if (is == 1) {
                            return;
                        }
                        is = 1;
                        if (!is_login) {
                            $.prompt('请先登录', {
                                buttons: {"确定": true},
                                submit: function (e, v, m, f) {
                                    if (v == true) {
                                        go_login(c_url);
                                    }
                                }
                            });
                        } else {

                            if (c_url != '') {
                                window.location.href = c_url;
                            }
                        }

                    } else {

                        if (c_url != '') {
                            window.location.href = c_url;
                        }
                    }


                }


                $(function () {

                    each_time_bg(); //活动图片倒计时
                    //count_time();   // 限时抢购倒计时
                    img_ratio();

                    $("#searchBtn").click(function () {
                        var keyword = $("#searchcon").val();
                        window.location.href = "/Goods/Index?keyword=" + keyword;
                    });



                });



                function go_login(redirect_url) {
                    $.cookie("ret_url", redirect_url, {expires: 1, path: '/'});
                    window.location.href = '/User/Login/';

                }

                function img_ratio() {

                    var sw = $(window).width();
                    if (sw > 640) {
                        sw = 640;
                    }

                    $('.img_r').each(function () {
                        var imgr = $(this).attr('img_r');

                        if (imgr != 0 && imgr != '' && imgr != undefined) {
                            $(this).css({'height': sw / imgr});
                        }

                    });
                }

                function go_top() {

                    $('body,html').animate({scrollTop: 0}, 1000);
                }

                var t_top = 0;
                window.onscroll = function () {

                    t_top = document.body.scrollTop;
                    if (t_top > 800) {
                        $('.go_top').show();
                    } else {
                        $('.go_top').hide();
                    }

                }
            </script>

        </div>
    </div>
</div>


@endsection
@section('footer')
     @include('common.footer')
@stop
